from fastapi import APIRouter, HTTPException
from pydantic import BaseModel

from app.services.llm_client import chat_with_qwen

router = APIRouter()

class ChatRequest(BaseModel):
    prompt: str

@router.post("/generate")
def generate_chat(req: ChatRequest):
    try:
        messages = [
            {"role": "system", "content": "你是一个直播话术助手，善于生成自然、吸引人的话术"},
            {"role": "user", "content": req.prompt},
        ]
        result = chat_with_qwen(messages)
        return {"result": result}
    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e))
